
project, uses(../data_output/termlimited_tmp.dta)



	use ../data_output/termlimited_tmp.dta, clear
	*****************************
	*Describe each variable in the dataset and save it as a note
	*****************************
	

	*Overall description of dataset and the variables that identifies each row.
	notes : "Each row in the dataset is uniquely identified by a state legislator in a given term. "
	
	*state
	notes state : "String variable that reports the state."	
	
	*state
	notes chamber : "String variable that reports the legislator serves in the upper chamber (==senate) or lower chamber (==house) in the state legislature in a particular term."	
		
	
	*CandId	
	notes CandId : "Discrete variable that uniquely identifies an individual state legislator. This is also the id in the Klarner dataset."
			
	*CandName
	notes CandName : "String variable reporting the name of the legislator. The format is {\bf Lastname, Forenames} with nicknames in parenthesis."	
	
	*party
	notes party : "String variable reporting the party of the legislator."	
	
	*term
	notes term : "String variable reporting the legislative term. The format is {\bf First Year, Last Year}, where First Year is the first year after the election in which the legislator was elected to office, and Last Year is the year of the subsequent general election."	
		
	*year
	notes year : "Discrete variable that reports the year in which the legislator was elected to office."
	
	*chamber_term
	notes chamber_term : "Discrete variable that identifies a particular term in a particular legislative chamber."
		
	*chamber_party_term
	notes chamber_party_term : "Discrete variable that identifies a party in a particular term in a particular legislative chamber."
		
	*cohort_term
	notes cohort_term: "Discrete variable that identifies a cohort-by-term observation where cohort is defined by the first year in which a legislator was elected to the legislature."
		
 
		
	
	
	********	
	//Term Limit Info
	********	
	*termlimited
	notes termlimited : "A dummy variable indicating whether the legislator is term limited (==1) or not (==0) in the particular term."
		
	*termlimits_effective
	notes termlimits_effective: "Discrete variable that reports the year when term limits took effect in a particular state."
	
	*termlimits_effective
	notes termlimits_effective_dummy: "Dummy variable that indicates whether term limits are effective in a particular state in particular term."
			
	*permitted_terms
	notes permitted_terms: "Discrete variable that reports the number of permitted terms a legislator can serve in a particular legislative chamber." 	
		
	*lifelimit
	notes lifelimit: "Dummy variable that indicates that the term limits in a particular state are a life-time ban."
					
	*lifelimitXtermlimited
	notes lifelimitXtermlimited: "Dummy variable that interacts the lifetime variable with the termlimited variable."
	
	*salary_per_day
	notes salary_per_day: "Continuous variable that reports the average compensation per legislative work day. The information comes from Bowen and Greene (2014)."

		
	notes rank_prof: "Continuous variable that reports the ranking of state legislatures with respect to professionalization. For ease of interpretation, the rankings are standardized such that the most professional legislature gets a score of 1 and the least professional legislature gets a score of 0. The information comes from Bowen and Greene (2014)."
	

		
		
		
	********	
	//Outcomes Info
	********		

	*pc1
	notes pc1 : "A continuous variable that summarizes the legislative productivity of the legislator in a particular term. The variable is constructed by extrating the first principal component from the variables log of sponsored bills, the index of committee activity, and the percent participation in floor votes. See details in the paper."
	
	*first_pc1
	notes first_pc1 : "A continuous variable that reports the pc1 in the first term of a legislator serves in office."
	
	
	*sponsored
	notes sponsored : "Discrete variable that counts the number of bills that the legislator sponsored in a particular term."
		
	*log_sponsored
	notes log_sponsored : "A continuous variable that takes the log of the sponsored bills."

	*first_log_sponsored
	notes first_log_sponsored : "A continuous variable that reports the log of sponsored bills in the first term of a legislator serves in office."
	
	* cmt_index
	notes cmt_index : "A continuous variable that measures a legislator's responsibilities and activities in legislative committees. See the paper for the full description of the construction of the index."
	
	*first_cmt_index
	notes first_cmt_index : "A continuous variable that reports the value of the committee activity index in the first term of a legislator serves in office."
	
	* pct_floorvotes
	notes pct_floorvotes : "A continuous variable that measures the percent of the total floor votes in a chamber in a particular term in which the legislator is recorded as having cast either a Yes or No vote according to the official roll calls."
	
	*first_pct_floor
	notes first_pct_floor : "A continuous variable that reports the value of percent of total floor votes that a legislator participated in during the first term in office."
	
	
	  
	
	* wnom
	notes wnom : "A continuous variable that reports the W-Nominate scalings. See the paper for additional details."

	* abs_wnom
	notes abs_wnom : "A continuous variable that reports the absolute value of the W-Nominate scaling."	
	
	*terms_in_office
	notes terms_in_office : "Discrete variable that counts the number of terms that a legislator has served in office."
		
	*max_terms_in_office
	notes max_terms_in_office : "Discrete variable that counts the total number of terms that a legislator served in office at the end of her legislative career."
				
		


	
	*****************************
	*Produce a .tex file containing the variable descriptions
	*****************************	
	
	
	* Add the following to Latex preamble: 
	* \usepackage[Q=yes,pverb-linebreak=no]{examplep}
	* \usepackage{enumitem}

	keep state chamber CandId CandName party term year chamber_term chamber_party_term cohort_term termlimited  termlimits_effective termlimits_effective_dummy permitted_terms lifelimit lifelimitXtermlimited salary_per_day rank_prof  ///
	pc1  first_pc1 first_log_sponsored first_cmt_index first_pct_floor sponsored log_sponsored cmt_index pct_floorvotes wnom abs_wnom terms_in_office max_terms_in_office rating* sig_name* sig_issues*	
	
	order state chamber CandId CandName party term year chamber_term chamber_party_term cohort_term termlimited  termlimits_effective termlimits_effective_dummy permitted_terms lifelimit lifelimitXtermlimited salary_per_day rank_prof  ///
	pc1  first_pc1 first_log_sponsored first_cmt_index first_pct_floor sponsored log_sponsored cmt_index pct_floorvotes wnom abs_wnom terms_in_office max_terms_in_office 
	

 
	
	
	ssc install distinct , replace
quietly {
		cap log close
		set linesize 255
		
		
		log using "../tables_figures/variables.tex", text replace
		
		loc note1 : char _dta[note1]
		noisily dis `note1'		
			
		noisily dis  " The dataset contains " c(k) " variables. Each variable is briefly described below. \\ "
		
	
		
		noisily dis	" \begin{description}[leftmargin=10em,style=nextline]"
		
	*	noisily dis "\item [ Variable] Short description."
		
		foreach v of varlist state chamber CandId CandName party term year chamber_term chamber_party_term cohort_term termlimited  termlimits_effective termlimits_effective_dummy permitted_terms lifelimit lifelimitXtermlimited salary_per_day rank_prof  ///
	pc1   sponsored log_sponsored cmt_index pct_floorvotes wnom max_terms_in_office {   // list all the variables in the dataset

			notes _fetch tmpnote : `v' 1
			local vartype: type `v'
			*if the variable is a string variable:
			if substr("`vartype'",1,3)=="str" { 
				distinct `v' 
				noisily dis "\item [ \Q{`v'}]  String variable. "
				noisily dis  `tmpnote' 
				noisily dis	"The variable has"
				noisily dis	%9.0fc r(N) " non-missing observations and"
				noisily dis	%9.0fc r(ndistinct) " distinct values."
				}

			
			*if the variable is a string variable:
			if substr("`vartype'",1,3)!="str" { 
				distinct `v' 			
				noisily dis "\item [ \Q{`v'}] Numeric variable. "
				noisily dis  `tmpnote' 
				noisily dis	"The variable has"
				noisily dis	%9.0fc r(N) " non-missing observations and"
				noisily dis	%9.0fc r(ndistinct) " distinct values."
				}		
		
			
		}
	
		noisily dis	" \end{description}"
		
		
		log off
	
	}
	
	
	save "../data_output/termlimited.dta", replace
project, creates(../data_output/termlimited.dta)


	